package flc.ast.activity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import com.blankj.utilcode.constant.TimeConstants;
import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.adapter.CumulativePasswordAdapter;
import flc.ast.bean.MyPassKindBean;
import flc.ast.databinding.ActivityCumulativePasswordBinding;
import flc.ast.utils.AppSpUtils;
import flc.ast.utils.Content;
import stark.common.basic.utils.SPUtil;

public class CumulativePasswordActivity extends BaseAc<ActivityCumulativePasswordBinding> {

    private CumulativePasswordAdapter passwordAdapter;
    private List<MyPassKindBean> listShow = new ArrayList<>();

    @Override
    protected int onCreate() {
        return R.layout.activity_cumulative_password;
    }

    @Override
    protected void initView() {
        mDataBinding.ivCumulativePasswordBack.setOnClickListener(v -> onBackPressed());

        mDataBinding.tvAddPassword.setOnClickListener(this);

        mDataBinding.rvCumulativePasswordList.setLayoutManager(new LinearLayoutManager(mContext));
        passwordAdapter = new CumulativePasswordAdapter();
        mDataBinding.rvCumulativePasswordList.setAdapter(passwordAdapter);
        passwordAdapter.setOnItemClickListener(this);
    }

    @Override
    protected void onClickCallback(View v) {
        switch (v.getId()) {
            case R.id.tvAddPassword://添加密码
                AddPasswordActivity.kindBean = listShow.get(0);
                startActivity(AddPasswordActivity.class);
                break;
        }
    }

    @Override
    protected void onItemClickCallback(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        PasswordActivity.kindBean = listShow.get(position);
        startActivity(PasswordActivity.class);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onResume() {
        super.onResume();
        getData();
    }

    //获取记录
    private void getData() {
        listShow.clear();
        List<MyPassKindBean> listSp = AppSpUtils.getPasswordList();
        listShow.addAll(listSp);
        passwordAdapter.setList(listShow);
    }

}